var default_width=1920;//默认宽度
var default_height=1080;//默认高度
var default_scale=default_width/default_height;//默认比例


$(window).ready(function () {          //当浏览器加载时
	 $(document.body).css({
		   "overflow-x":"hidden",
		   "overflow-y":"hidden"
		 });
	var actual_width= document.documentElement.clientWidth;
	var actual_height= document.documentElement.clientHeight;
	var actual_scale=actual_width/actual_height;//实际比例
	var w=actual_width/default_width;
	var h=actual_height/default_height;
	if(actual_scale>default_scale){
		$(document.body).css("-webkit-transform", "scale("+h+","+h+")");
		$(document.body).css("-moz-transform", "scale("+h+","+h+")");
		$(document.body).css("-o-transform", "scale("+h+","+h+")");
		$(document.body).css("-ms-transform", "scale("+h+","+h+")");
		$(document.body).css("transform", "scale("+h+","+h+")");
	}
	if(actual_scale<default_scale){
		$(document.body).css("-webkit-transform", "scale("+w+")");
		$(document.body).css("-moz-transform", "scale("+w+")");
		$(document.body).css("-o-transform", "scale("+w+")");
		$(document.body).css("-ms-transform", "scale("+w+")");
		$(document.body).css("transform", "scale("+w+")");
	}
	scrollToCenter();
});

$(window).resize(function () {          //当浏览器长宽变化时
	 $(document.body).css({
		   "overflow-x":"hidden",
		   "overflow-y":"hidden"
		 });
	var actual_width= document.documentElement.clientWidth;
	var actual_height= document.documentElement.clientHeight;
	var actual_scale=actual_width/actual_height;//实际比例
	var w=actual_width/default_width;
	var h=actual_height/default_height;
	if(actual_scale>default_scale){
		$(document.body).css("-webkit-transform", "scale("+h+")");
		$(document.body).css("-moz-transform", "scale("+h+")");
		$(document.body).css("-o-transform", "scale("+h+")");
		$(document.body).css("-ms-transform", "scale("+h+")");
		$(document.body).css("transform", "scale("+h+")");
	}
	if(actual_scale<default_scale){
		$(document.body).css("-webkit-transform", "scale("+w+")");
		$(document.body).css("-moz-transform", "scale("+w+")");
		$(document.body).css("-o-transform", "scale("+w+")");
		$(document.body).css("-ms-transform", "scale("+w+")");
		$(document.body).css("transform", "scale("+w+")");
	}
	scrollToCenter();
});
function  scrollToCenter(){
	var now_width = document.documentElement.clientWidth;
	var now_height= document.documentElement.clientHeight;
	var Top;
	var Left;
	Top=(default_height-now_height)/2;
	Left=(default_width-now_width)/2;
	$(document.body).scrollTop(Top);
	$(document.body).scrollLeft(Left);
}